import 'package:flutter/cupertino.dart';
import 'package:hitutor/Util/Global.dart';
import 'package:hitutor/Util/MyColor.dart';
import 'package:hitutor/Widget/MyImage.dart';
import 'package:hitutor/Widget/MyInput.dart';
import 'package:hitutor/Widget/MyPage.dart';
import 'package:webview_flutter/webview_flutter.dart';

class HelpCenter extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _HelpCenter();
  }
}

class _HelpCenter extends State<HelpCenter> {
  String helpCenterUrl = "http://wb.hitutor.com.tw/site/member_tw/faq/faq.php";
  @override
  Widget build(BuildContext context) {
    return MyPage(
        "幫助中心",
        Container(
            decoration: Global.getBg(MyColor.White, 0),
            child: WebView(initialUrl: helpCenterUrl, javascriptMode: JavascriptMode.unrestricted))
        // Container(
        //     child: SingleChildScrollView(
        //   padding: EdgeInsets.all(8),
        //   child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
        //     Container(
        //         height: 32,
        //         margin: EdgeInsets.all(12),
        //         padding: EdgeInsets.only(left: 16),
        //         decoration: Global.getBg(MyColor.F3, 6),
        //         child: Row(children: [
        //           Expanded(
        //               child: NormalInput(
        //             hintText: "輸入問題或問題關鍵字",
        //           )),
        //           LocalImage("search_blue.png", padding: EdgeInsets.all(6)),
        //         ])),
        //     Padding(
        //         padding: EdgeInsets.fromLTRB(8, 16, 8, 16),
        //         child: Text("常見問題", style: TextStyle(color: MyColor.C99, fontWeight: FontWeight.bold, fontSize: 12))),
        //     ItemQuestion("系統相關維護公告"),
        //     Container(height: 0.8, color: MyColor.EE),
        //     ItemQuestion("訂課流程"),
        //     Container(height: 0.8, color: MyColor.EE),
        //     ItemQuestion("換課說明"),
        //     Container(height: 0.8, color: MyColor.EE),
        //     ItemQuestion("訂課異常"),
        //     Container(height: 0.8, color: MyColor.EE),
        //     ItemQuestion("如何取消課程"),
        //     Container(height: 0.8, color: MyColor.EE),
        //     ItemQuestion("關於申請帳號暫停"),
        //     Container(height: 0.8, color: MyColor.EE),
        //     ItemQuestion("帳號安全"),
        //     Container(height: 0.8, color: MyColor.EE),
        //     Padding(
        //         padding: EdgeInsets.fromLTRB(8, 24, 8, 16),
        //         child: Text("聯絡我們", style: TextStyle(color: MyColor.C99, fontWeight: FontWeight.bold, fontSize: 12))),
        //     ItemContact("ic_line.png", "Line ID：@hiacdm"),
        //     ItemContact("ic_email.png","Email：hitutor@hitutor.com.tw"),
        //     ItemContact("ic_tel.png","Phone：04-3704-2882"),
        //   ]),
        // )),
    );
  }
}

class ItemQuestion extends StatelessWidget {
  String title;
  Function()? onTap;

  ItemQuestion(this.title, {this.onTap});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
        onTap: () {},
        child: Container(
          padding: EdgeInsets.all(8),
          child: Row(
            children: [
              Expanded(child: Text(title, style: TextStyle(color: MyColor.C7D, fontWeight: FontWeight.bold, fontSize: 13))),
              LocalImage("right_arrow.png", width: 12)
            ],
          ),
        ));
  }
}

class ItemContact extends StatelessWidget {
  String icon;
  String text;

  ItemContact(this.icon, this.text);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 48,
      child: Row(
        children: [
          LocalImage(icon, width: 28, padding: EdgeInsets.all(8)),
          Text("$text", style: TextStyle(color: MyColor.C7D, fontSize: 13))
        ],
      ),
    );
  }
}
